﻿using System;
using System.Collections.Generic;
using System.Drawing;
using RaytracerLib.Layers;
using RaytracerLib.MathLib;
using TomanuExtensions;
using RaytracerLib.Layers.OverlayCorrectors;
using System.Linq;
using RaytracerLib.Postprocessing;
using System.Diagnostics;

namespace RaytracerLib.Resamplers
{
    public struct PixelInterpolator
    {
        private ColorFloat m_numerator;
        private double m_denumerator;

        /// <summary>
        /// Note: a_ray_color in SRGB space.
        /// </summary>
        /// <param name="a_ray_color"></param>
        /// <param name="a_filter_weight"></param>
        public void Collect(ColorFloat a_ray_color, double a_filter_weight)
        {
            m_numerator += a_ray_color * a_filter_weight;
            m_denumerator += a_filter_weight;
        }

        /// <summary>
        /// Note: color in SRGB space.
        /// </summary>
        public ColorFloat Color
        {
            get
            {
                if (m_denumerator == 0)
                    return ColorFloat.Black;

                return m_numerator / m_denumerator;
            }
        }

        public override string ToString()
        {
            return String.Format("num: {0}, denum: {1}", m_numerator, m_denumerator);
        }
    }
}